<?php

namespace tbollmeier\kakuromaster\core;

class Cell {

    public $values; 

    public function __construct($id, $row, $col, $values)
    {
        $this->id = $id;
        $this->row = $row;
        $this->col = $col;
        $this->values = $values;
        $this->groups = [];
    }
    
    public function addGroup($group, $mutual=true)
    {
        array_push($this->groups, $group);
        if ($mutual) {
            $group->addCell($this, false);    
        }
    }
    
    public function getId()
    {
        return $this->id;
    }
    
    public function getRow()
    {
        return $this->row;
    }
    
    public function getColumn()
    {
        return $this->col;
    }
    
    public function getGroups()
    {
        return $this->groups;
    }
    
    public function getOtherGroups($group)
    {
        return array_filter($this->groups,
                            function($g) use ($group)
                            {
                                return $g->getId() != $group->getId();
                            });
    
    }
   
    private $id;
    private $row;
    private $col;
    private $groups;
}
